package no.rodland.acc.utils;

import java.util.regex.Pattern;

/**
 * Created by IntelliJ IDEA.
 *
 * @Since: Jun 30, 2010 10:47:02 AM
 * @Author: fmr
 */
public class NumberUtil {

    private static final Pattern NUMBER_PATTERN = Pattern.compile(".*?([\\.\\-0-9]*).*?");

    public static int getInt(String s) {
        return (int) getLong(s);
    }

    public static long getLong(String s) {
        return Math.round(getDouble(s));
    }

    public static double getDouble(String s) {
        if (s == null || s.length() == 0) {
            return 0;
        }
        s = s.replaceAll("[^0-9\\.-]+", "");
        return Double.parseDouble(s);
    }
}
